<include file="public/layout"/>
<load href="__ROOT__/public/plugins/Ueditor/ueditor.config.js"/>
<load href="__ROOT__/public/plugins/Ueditor/ueditor.all.min.js"/>
<script type="text/javascript" charset="utf-8" src="__ROOT__/public/plugins/Ueditor/lang/zh-cn/zh-cn.js"></script>
<script src="__ROOT__/public/static/js/layer/laydate/laydate.js"></script>

<style type="text/css">
    html, body {
        overflow: visible;
    }
</style>
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer"
     style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>参数管理 - 最新公告</h3>
                <h5></h5>
            </div>
        </div>
    </div>
    <form class="form-horizontal" action="{:U('Home/saveIndexNotice')}" id="add_post" method="post">
        <div class="ncap-form-default">
            <dl class="row">
                <dd class="opt">
                    <textarea class="span12 ckeditor" id="site_notice" name="site_notice" title="">
                        {$info.site_notice}
                    </textarea>
                    <span class="err" id="err_site_notice"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
            <div class="bot">
                <a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
            </div>
        </div>
        <input type="hidden" name="is_ajax" value="1">
    </form>
</div>
<script type="text/javascript">

    $(function () {
        $('#publish_time').layDate();
    });

    var url = "{:url('Ueditor/index',array('savePath'=>'notice'))}";
    var ue = UE.getEditor('site_notice', {
        serverUrl: url,
        zIndex: 999,
        initialFrameWidth: "80%", //初化宽度
        initialFrameHeight: 300, //初化高度            
        focus: false, //初始化时，是否让编辑器获得焦点true或false
        maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
        pasteplain: false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
        autoHeightEnabled: true
    });

    $(document).on("click", '#submitBtn', function () {
        verifyForm();
    });

    function verifyForm() {
        $('span.err').hide();
        $.ajax({
            type: "POST",
            url: "{:U('Home/saveIndexNotice')}",
            data: $('#add_post').serialize(),
            dataType: "json",
            error: function () {
                layer.alert("服务器繁忙, 请联系管理员!");
            },
            success: function (data) {
                if (data.status === 1) {
                    layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                        location.href = "{:U('Admin/Home/saveIndexNotice')}";
                    });
                } else if (data.status === 0) {
                    layer.msg(data.msg, {icon: 2, time: 1000});
                } else {
                    layer.msg(data.msg, {icon: 2, time: 1000});
                }
            }
        });
    }
</script>
</body>
</html>